﻿using GBT.Business.GBT_Base_Manage;
using GBT.Entity.GBT_Base_Manage;
using GBT.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace GBT.AmoebaManage.Controllers.GBT_Base_Manage
{
    [Route("/GBT_Base_Manage/[controller]/[action]")]
    public class GBT_Base_AccountController : BaseApiController
    {
        #region DI

        public GBT_Base_AccountController(IGBT_Base_AccountBusiness gBT_Base_AccountBus)
        {
            _gBT_Base_AccountBus = gBT_Base_AccountBus;
        }

        IGBT_Base_AccountBusiness _gBT_Base_AccountBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<GBT_Base_Account>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _gBT_Base_AccountBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<GBT_Base_Account> GetTheData(IdInputDTO input)
        {
            return await _gBT_Base_AccountBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(GBT_Base_Account data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _gBT_Base_AccountBus.AddDataAsync(data);
            }
            else
            {
                await _gBT_Base_AccountBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _gBT_Base_AccountBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}